﻿#include "StdAfx.h"
#include "CLIFactoryMethod.h"

using namespace System;
using namespace System::Collections;
namespace $RootNamespace$
{

	System::String ^CLIDefaultProduct::GetProductName()
	{
		return "default";
	}

	$IProduct$ ^CLIConcreteDefaultCreator::FactoryMethod()
	{
		return gcnew CLIDefaultProduct();
	
	}

	void $Creator$::AnOperation()
	{
		$IProduct$ ^product = FactoryMethod();
		Console::WriteLine("In $Creator$.AnOperation(): created " + product->GetProductName());
	
	}

	void $Creator$::Test()
	{
		array<$Creator$^> ^creators = gcnew array<$Creator$^> { gcnew CLIConcreteCreator1(), gcnew CLIConcreteCreator2(), gcnew CLIConcreteDefaultCreator()};
	
		for each($Creator$ ^c in creators)
		{
			c->AnOperation();
			$IProduct$ ^product = c->FactoryMethod();
			Console::WriteLine("In $Creator$.Main() Name= " + product->GetProductName());
		}
	
	}

	System::String ^CLIProduct1::GetProductName()
	{
		return "CLIProduct1";
	}

	$IProduct$ ^CLIConcreteCreator1::FactoryMethod()
	{
		return gcnew CLIProduct1();
	
	}

	System::String ^CLIProduct2::GetProductName()
	{
		return "CLIProduct2";
	}

	$IProduct$ ^CLIConcreteCreator2::FactoryMethod()
	{
		   return gcnew CLIProduct2();
	
	}
}